<%@ page language="java"
         contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"
         import="com.shxt.hotel.background.User"
%>
<%
    request.setCharacterEncoding("UTF-8");
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    
    User user = new User();
    int rslt = user.login(username, password);
    
    String location = "";
    switch(rslt){
        case User.STAFF_NAME_ERROR:
            out.println("用户名错误");
            location = "../login.jsp?msg=username+not+exist";
            break;
        case User.PASSWORD_ERROR:
            out.println("密码错误");
            location = "../login.jsp?msg=password+wrong";
            break;
        case User.SUCCESS:
            out.println("成功");
            location = "../index.jsp";
            break;
        default:
            break;
    }
    
    session.setAttribute("id", user.getUserId());
    
    user.close();
    response.sendRedirect(location);
%>